package com.nefu.editor.core.mapper.provider;

import com.nefu.editor.core.model.Notice;
import org.apache.ibatis.jdbc.SQL;

public class NoticeProvider {

    public String selectNoticeByCondition(Notice notice) {
        return new SQL() {
            {
                SELECT("notice_systemId As systemId, notice_senderId as senderId, notice_receiverId as receiverId, notice_type as type," +
                        "notice_flag as flag, notice_time as time, notice_text as text");
                FROM("t_notice");
                if (null != notice.getSystemId()) {
                    WHERE("notice_systemId=#{systemId}");
                }
                if (null != notice.getSenderId()) {
                    WHERE("notice_senderId=#{senderId}");
                }
                if (null != notice.getReceiverId()) {
                    WHERE("notice_receiverId=#{receiverId}");
                }
                if (null != notice.getType()) {
                    WHERE("notice_type=#{type}");
                }
            }
        }.toString();
    }

}
